<template>
  <div class="home">
    <swiper :imgList="imgList"> </swiper>
    <ul class="mui-table-view mui-grid-view mui-grid-9">
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <!-- <router-link :to="{ name: 'news_list' }"> -->
        <router-link to="/news/list">
          <img src="../assets/images/menu1.png" alt="" />
          <div class="mui-media-body">新闻资讯</div>
        </router-link>
      </li>
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <router-link to="/photo/list">
          <img src="../assets/images/menu2.png" alt="" />
          <div class="mui-media-body">图片分享</div>
        </router-link>
      </li>
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <router-link to="/category">
          <img src="../assets/images/menu3.png" alt="" />
          <div class="mui-media-body">商品购买</div>
        </router-link>
      </li>
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <router-link to="/category">
          <img src="../assets/images/menu4.png" alt="" />
          <div class="mui-media-body">留言反馈</div>
        </router-link>
      </li>
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <router-link to="/category">
          <img src="../assets/images/menu5.png" alt="" />
          <div class="mui-media-body">视频专区</div>
        </router-link>
      </li>
      <li class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3">
        <router-link to="/category">
          <img src="../assets/images/menu6.png" alt="" />
          <div class="mui-media-body">联系我们</div>
        </router-link>
      </li>
    </ul>
  </div>
</template>

<script>
import swiper from "../components/swiper.vue";
export default {
  data() {
    return {
      imgList: [],
    };
  },
  methods: {
    getImgList() {
      //相当于是一个loading 加载效果
      this.$indicator.open({ text: "加载中..." });
      this.$http.get("imglist").then((res) => {
        // get方式 请求路径是imglist 获取到之后 then (之后) 打印结果
        // 在请求得到结果之后 关闭loading效果
        console.log(res.data);
        this.$indicator.close({ text: "加载中..." });
        if (res.data.code === 0) this.$toast("加载轮播数据失败");
        //$toast 是mui提供出来的弹窗
        else {
          this.imgList = res.data.data;
        }
      });
    },
  },
  name: "Home",
  components: {
    swiper,
  },
  created() {
    this.getImgList();
  },
};
</script>
<style scoped>
.mui-grid-view.mui-grid-9 {
  background-color: #fff;
  border: none;
}
img {
  width: 60px;
  height: 60px;
}
.mui-grid-view.mui-grid-9.mui-table-view-cell {
  border: 0;
}
.mui-media-body {
  font-size: 14px;
}
</style> 
